@extends('layouts.web')

@section('title', '免费目录提交_'.env('APP_NAME').'_我们只推荐好网站')
@section('keywords', env('APP_NAME').','.env('APP_NAME').'资讯,网站综合查询,免费网站目录外链')
@section('description', '免费获取的网站流量也是中小网站和新网站推广首选网络推广服务平台！'.env('APP_NAME').'给大家提供国内外网址大全，整理和收藏网站导航！您也可以在我们的免费发布自己的网站及网站相关信息！')

@section('content')
    <div class="main-container">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header none-border">
                        <div class="layui-breadcrumb" style="visibility: visible;">
                            <a href="{{ url('/') }}">首页</a>
                            <span lay-separator="">/</span>
                            <a><cite>目录提交</cite></a>
                        </div>
                    </div>
                </div>
                <div class="layui-card">
                    <form class="layui-form layui-form-pane" action="{{ route('submit.create') }}" method="post">
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" required="" lay-verify="required" placeholder="例如：百度" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">网站地址</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" required="" lay-verify="required" placeholder="例如：www.baidu.com" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">所属分类</label>
                            <div class="layui-input-inline">
                                <select name="column1" lay-verify="required" lay-filter="column1" id="column1">
                                    <option value="">请选择一级分类</option>
                                    <script id="js_column1" type="text/html">
                                    <option value="">请选择一级分类</option>
                                    @verbatim
                                        {{#  layui.each(d.list, function(index, item){ }}
                                            {{#  if(item.parent_id == 0){ }}
                                                <option value="{{ item.id }}">{{ item.title }}</option>
                                            {{#  } }}
                                        {{#  }); }}
                                    @endverbatim
                                    </script>
                                </select>
                            </div>
                            <div class="layui-input-inline">
                                <select name="column2" lay-verify="required" lay-filter="column2" id="column2">
                                    <option value="">请先选择一级分类</option>
                                    <script id="js_column2" type="text/html">
                                    <option value="">请选择二级分类</option>
                                    @verbatim
                                        {{#  layui.each(d.list, function(index, item){ }}
                                            {{#  if(item.parent_id == d.id){ }}
                                                <option value="{{ item.id }}">{{ item.title }}</option>
                                            {{#  } }}
                                        {{#  }); }}
                                    @endverbatim
                                    </script>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">所属地域</label>
                            <div class="layui-input-inline">
                                <select name="city" lay-verify="">
                                  <option value="">请选择所属地域</option>
                                  @foreach($areas as $v)
                                    <option value="{{ $v->id }}">{{ $v->name }}</option>
                                  @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label">网站简介</label>
                            <div class="layui-input-block">
                                <textarea placeholder="请输入内容" class="layui-textarea" lay-verify=""></textarea>
                            </div>
                        </div>
        				<div class="layui-form-item">
        					<label class="layui-form-label">滑动验证</label>
        					<div class="layui-input-block">
        						<div id="slider"></div>
        					</div>
        				</div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                              <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('scriptsAfterJs')
<script>
    layui.use(['layer', 'form', 'jquery', 'laytpl', 'sliderVerify'], function(){
        var layer = layui.layer, $ = layui.jquery, form = layui.form, laytpl = layui.laytpl, sliderVerify = layui.sliderVerify;
        localStorage.clear();
        //渲染
        var dataList    = {!! $column !!}
        html_all(dataList, 'column1');
        
        form.on('select(column1)', function(data){
            dataList['id']    = data.value;
            html_all(dataList, 'column2');
        });
        
        function html_all(data, type)
        {
            var dom = localStorage.getItem('js_'+type);
            if (dom)
            {
                var getTpl = dom,view = document.getElementById(type);
                laytpl(getTpl).render(data, function(html){
                    view.innerHTML = html;
                });
            } else {
                dom     = document.getElementById('js_'+type).innerHTML;
                localStorage.setItem('js_'+type, dom);
                var getTpl = dom,view = document.getElementById(type);
                laytpl(getTpl).render(data, function(html){
                    view.innerHTML = html;
                });
            }
            form.render('select');
        }
        
        var slider = sliderVerify.render({
			elem: '#slider',
			onOk: function(){//当验证通过回调
				layer.msg("滑块验证通过");
			}
		})
		//监听提交
		form.on('submit(formDemo)', function(data) {
			if(slider.isOk()){
				layer.msg(JSON.stringify(data.field));
			}else{
				layer.msg("请先通过滑块验证");
			}
			return false;
		});
    });
</script>
@endsection